<template>
	<div>
		<div>
			<van-nav-bar title="支付" left-text="返回" left-arrow @click-left="back()" />
		</div>
		<div style="width: 100%;">
			<van-cell title="订单创建" :value=PayMsg.createBy />
			<van-cell title="创建时间" :value=PayMsg.createTime />
			<van-cell title="订单编号" :value=PayMsg.id />
			<van-cell title="预约编号" :value=PayMsg.maintenanceAppointmentId />
			<van-cell title="订单状态" :value="(PayMsg.status==0)?'待支付':'已支付'" />
		</div>
		<div>
			<van-submit-bar :price="PayMsg.price*100" :decimal-length=0 button-text="支付" @submit="payfor" />
		</div>
	</div>
</template>

<script>
	import request from '@/util/request'
	export default {
		name: 'pay',
		data() {
			return {
				PayMsg: [],
			}
		},
		created() {
			this.getPayMsg()
		},
		methods: {
			back() {
				this.$router.back()
			},
			getPayMsg() {
				request({
					url: 'dev-api/bs-vehicle-owner/maintenance-pay/' + window.localStorage.getItem(
						'maintenancePaymentId'),
					method: 'get'
				}).then(res => {
					this.PayMsg = res.data
				})
			},
			payfor() {
				request({
					url: '/dev-api/bs-vehicle-owner/maintenance-pay',
					method: 'put',
					data: {
						"id": this.PayMsg.id,
						"maintenanceAppointmentId": this.PayMsg.maintenanceAppointmentId,
						"price": this.PayMsg.price,
						"status": 1
					}
				}).then(res => {
					if(res.data == 1){
						this.$toast.success("支付成功")
						this.$router.push({
							path:'/service'
						})
					}else{
						this.$toast.fail("提交失败："+res.msg)
					}
				})
			}
		}
	}
</script>

<style>
</style>
